<include file="public/header" />
<body class="login-bg">

<div class="login layui-anim layui-anim-up">
  <div class="message">-商家管理端</div>
  <div id="darkbannerwrap"></div>

  <form method="post" action="{:url('admin/login')}" class="layui-form" >
    <input name="username" placeholder="用户名"  type="text" lay-verify="required" class="layui-input" >
    <hr class="hr15">
    <input name="password" lay-verify="required" placeholder="密码"  type="password" class="layui-input">
    <hr class="hr15">
    <button lay-submit lay-filter="login" class="layui-btn">登录
    </button>
    <hr class="hr20" >
  </form>
</div>

<script>

  layui.use(['form', 'layedit', 'laydate', 'layer', 'element'], function () {
    var $ = layui.jquery, layer = layui.layer
    var form = layui.form
            , layer = layui.layer
    //自定义验证规则
    form.verify({
      username: function (value) {
        if (value.length < 1) {
          return '请输入帐号';
        }
      },
      password: function (value, item) {
        if (!value) {
          return '请输入密码';
        }
      }
    });
    //监听提交
    form.on('submit(login)', function (data) {
      $.post($('form').attr('action'), data.field, function (data) {
        if (data.status == 1) {

          //   alert(data.status)

          setTimeout(function () {
            window.location.href = data.url
          }, 1000);
        } else {
          layer.msg(data.msg);
        }
        //  animated()
      });
      // layer.alert(JSON.stringify(data.field), {
      //     title: '最终的提交信息'
      // })
      return false;
    });
    //

    var browser = navigator.appName
    var b_version = navigator.appVersion
    var version = b_version.split(";");
    if (isFirefox = navigator.userAgent.indexOf("Firefox") > 0) {
      var trim_Version = 'Firefox';
    } else {
      var trim_Version = version[1].replace(/[ ]/g, "");
    }
    //兼容ie浏览器不显示placeholder属性
    if (trim_Version == 'MSIE9.0' || trim_Version == 'MSIE8.0' || trim_Version == 'MSIE7.0' || trim_Version == 'MSIE5.0') {

      $("input").each(function () {
        $(this).parent().find('.tip').addClass('on');
      });
    } else {
      $("input").click(function () {
        $(this).parent().find('.tip').addClass('on');
      });
      $("input").focus(function () {
        $(this).parent().find('.tip').addClass('on');
      });

      $("input").blur(function () {
        if ($(this).val() == '') {
          $(this).parent().find('.tip').delay(2000).removeClass('on');
        }
      });
    }

  });
</script>
<!-- 底部结束 -->
</body>
</html>